package 力扣日常刷题.木22二月.第06天212;

/**
 * @author 帅小伙
 * @date 2022/2/12
 * @description
 */
public class Demo43跳跃游戏2 {


    public int jump(int[] nums) {
        int step = 0;
        int end = 0, max = 0, n = nums.length;
        for (int i = 0; i < n - 1; i++) {
            max = Math.max(max,i+nums[i]);
            if(end == i){
                end = max;
                step ++;
            }
        }
        return step;
    }

}
